package com.pingan.agentbank.aaos.service;
/**
 * Title:
 * Description:Generate by isql(lianght).
 * @Copyright: Copyright (c) 2008
 * @Company: CORSWORK
 * @author: lianght
 * @version: 1.0.0
 * @time: Tue Dec 18 13:42:21 CST 2018
 * 
 * Create by isql command:
 * file appro_file_v1 com.pa.agentbank.aaos.service.ApproFile
 */

import com.pingan.agentbank.aaos.dao.ApproFileDao;
import com.pingan.agentbank.aaos.pojo.ApproFileInfo;

import java.util.*;

import com.pingan.vframe.db.DBIterator;
import com.pingan.vframe.lang.*;
import com.pingan.vframe.util.JaDateTime;
/**
 * Class description:ApproFileDaoService
 * 
 * @author 
 */
public class ApproFileDaoService {
	@Inject
    ApproFileDao dao;

	public ApproFileInfo getApproFileInfoByKey(int id) {
		return dao.get(id);
	}

	public int saveOneApproFileInfo(ApproFileInfo info) {
		boolean hasInDB = dao.get(info) != null;
		int count = 0;
		if(hasInDB) {
			count = dao.update(info);
		} else {
			count = dao.insert(info);
		}
		return count;
	}

	public int countAllApproFileInfo() {
		return dao.countAll();
	}

	public List<ApproFileInfo> pageApproFileInfos(int offset, int size) {
		return dao.pageApproFileInfos(offset, size);
	}

	public int deleteOneApproFileInfo(int id) {
		return dao.delete(id);
	}

	public int deleteApproFileInfos(String pks) {
		int count = 0;
		if (pks != null) {
			String[] arr_codes = pks.split(",");
			for (String code:arr_codes) {
				count += dao.delete(code);
			}
		}
		return count;
	}
	
	//user-defined

	//query
	public List<ApproFileInfo> queryOverDue(JaDateTime time){
		return dao.queryOverDue(time);
	}

	public DBIterator<ApproFileInfo> queryByState(int state){
		return dao.queryByState(state);
	}

	public ApproFileInfo queryById(Long id){
		return dao.get(id);
	}

	public DBIterator<ApproFileInfo> queryAll(){
		return dao.queryAll();
	}

	//update
	public int updateStateById(int state,int id){
		return dao.updateStateById(state,id);
	}

	public int updateCountAndStateById(int count,int state,int id){
		return dao.updateCountAndStateById(count,state,id);
	}

	public int updateResultNameAndStateById(String resultFileName,int state,int id){
		return dao.updateResultNameAndStateById(resultFileName,state,id);
	}



}
